#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int num, i, x;
	int j = 1;
	int k = 0;
	scanf("%d", &num);
	for (i = 1;; i++) {
		x = num % 10;
		if (x % 2 == i % 2)
			k += j;
		j *= 2;
		if (num / 10 == 0)
			break;
		num = num / 10;
	}
	printf("%d", k);
	return 0;
}